package com.cn.wxwinnie.java.mythread.tickets;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 潇湘暮雨 E-mail:wxwinnie@hotmail.com
 * 
 * @version 创建时间：2014年3月27日 下午9:08:26
 * 
 */
public class TicketsPool {
	private List<Integer> tickets = new ArrayList<Integer>();

	private final static TicketsPool tp = new TicketsPool();

	public static TicketsPool getInstance() {
		return tp;
	}

	public synchronized int removeTicket() {
		if (tickets.size() > 0)
			return tickets.remove(tickets.size() - 1);
		else
			return -1;
	}

	private TicketsPool() {
		for (int i = 0; i < 80; i++)
			tickets.add(i);
	}

}
